import instance from '@/utils/myhttp.js'

function apiArticleList (channelid) {
  return instance({
    url: '/app/v1_1/articles',
    method: 'get',
    params: {
      channel_id: channelid,
      timestamp: Date.now(),
      with_top: 0
    }
  })
}

// 将文章标记为不喜欢
function apiDisLike (target) {
  return instance({
    url: '/app/v1_0/article/dislikes',
    method: 'post',
    data: {
      target: target
    }
  })
}

// 举报文章
function apiReport ({ artid, type }) {
  return instance({
    url: '/app/v1_0/article/reports',
    method: 'post',
    data: {
      target: artid,
      type: type,
      remark: ''
    }
  })
}
// 拉黑用户
function apiBlackLike (autid) {
  return instance({
    url: '/app/v1_0/user/blacklists',
    method: 'post',
    data: {
      target: autid
    }
  })
}

// 文章详情/app/v1_0/articles/:article_id
function apiGetDetail (artid) {
  return instance({
    url: `/app/v1_0/articles/${artid}`,
    method: 'get'
  })
}

// 对文章点赞/app/v1_0/article/likings
function apiZan (artid) {
  return instance({
    url: '/app/v1_0/article/likings',
    method: 'post',
    data: {
      target: artid
    }
  })
}

// 取消对文章的点赞/app/v1_0/article/likings/:target
function apiGetDisZan (artid) {
  return instance({
    url: `/app/v1_0/article/likings/${artid}`,
    method: 'DELETE'
  })
}

// 取消对文章的不喜欢/app/v1_0/article/dislikes/:target
function apiCancelLike (artid) {
  return instance({
    url: `/app/v1_0/article/dislikes/${artid}`,
    method: 'DELETE'
  })
}

export {
  apiArticleList,
  apiDisLike,
  apiReport,
  apiBlackLike,
  apiGetDetail,
  apiZan,
  apiGetDisZan,
  apiCancelLike
}
